Skip to content

feat(bgp): follow the brownfield module's Gradle excludes in the published metadata - #522

Merged
hurali97 merged 4 commits into
callstack:mainfrom
KisaneNeko:feat/bgp-exclude-dependencies
Nov 9, 2026
Merged

hurali97 merged 4 commits into
callstack:mainfrom
KisaneNeko:feat/bgp-exclude-dependencies

Conversation

@KisaneNeko

Copy link
Copy Markdown
Contributor

Problem

The plugin builds the published dependency list from what embedded libraries declare, not from what Gradle resolves. A dependency excluded with configurations.all { exclude(...) } was still injected into the POM and module.json, so the host app resolved it anyway. For example, com.caverock:androidsvg and com.caverock:androidsvg-aar ship the same classes and the host failed with duplicate classes. A custom task that edits module.json doesn't help, because brownfieldRemoveDependenciesFromModuleFile injects the dependency again after it.

Change

  • GradleExclude.kt, RNBrownfieldPlugin.kt: exclude rules on the brownfield module's implementation, api, runtimeOnly and embed configurations keep a dependency out of the published files. :app's rules, variant-specific configurations and dependency-level excludes are not read.
  • PublishingMetadataInjector.kt: injected dependencies carry the same rules as <exclusions> in the POM and excludes in module.json, as Gradle does for the dependencies it writes, so the excluded library can't arrive through one of them.
  • Expo config plugin and CLI: android.expo.excludeDependencies in brownfield.config.json (or android.excludeDependencies in app.json), as group:module or group. Prebuild writes them into the generated module as a configurations.all { exclude(...) } block. Types, schema.json, the scaffold config and configuration.mdx are updated.
  • README "About Dependencies" section.

Verified with RNApp (configurations.all exclude of gson and a group-only androidx.swiperefreshlayout) and ExpoApp57 (android.expo.excludeDependencies: ["com.caverock:androidsvg-aar"]): neither stays a dependency in the published POM or module.json.

Before merging

Rerun those two publishes: they ran before the injected dependencies got the <exclusions>, which is only unit tested so far.

…ished metadata

The plugin builds the published dependency list from what embedded
libraries declare, not from what Gradle resolves, so a dependency excluded
with configurations.all { exclude(...) } was still added to the POM and
module.json, and the host app resolved it. Exclude rules on the brownfield
module's implementation, api, runtimeOnly and embed configurations now
keep a dependency out. :app's rules and variant-specific ones are not read.

On Expo, where prebuild regenerates the module, android.expo.excludeDependencies
("group:module" or "group") is written into it as those exclude rules.
Gradle publishes a configuration-level exclude as an exclusion on the
dependencies it declares, but not on the ones the plugin injects, so an
excluded library could still reach the host through one of them. The
injected POM and module.json entries now carry the same exclusions.

Also pulls the never-publish rule out of the plugin's wiring so a test
covers it, rejects a non-list android.excludeDependencies with a clear
message, and splits up the README section.
@KisaneNeko
KisaneNeko marked this pull request as ready for review November 5, 2026 17:47
@hurali97
hurali97 merged commit 20776bb into callstack:main Nov 9, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants